package com.yuhang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuhang.entity.HyBillStream;
import com.yuhang.entity.HyComplaints;
import com.yuhang.entity.StateMonth;
import com.yuhang.mapper.HyComplaintsMapper;
import com.yuhang.service.HyComplaintsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yuhang
 * @since 2021-04-25
 */
@Service
public class HyComplaintsServiceImpl extends ServiceImpl<HyComplaintsMapper, HyComplaints> implements HyComplaintsService {

    @Autowired
    private HyComplaintsMapper hyComplaintsMapper;

    @Override
    public IPage<HyComplaints> selectByPage(int pageNum, int pageSize,String likename) {
        Page<HyComplaints> page = new Page(pageNum,pageSize);
        QueryWrapper<HyComplaints> qw = new QueryWrapper();
        if(likename!=null&&!likename.equals("")){
            qw.like("complaints_name",likename);
        }
        IPage<HyComplaints> iPage = hyComplaintsMapper.selectPage(page,qw);
        return iPage;
    }

    @Override
    public IPage<HyComplaints> selectByPage(int pageNum, int pageSize, String likename, int userid) {
        Page<HyComplaints> page = new Page(pageNum,pageSize);
        QueryWrapper<HyComplaints> qw = new QueryWrapper();
        qw.eq("user_id",userid);
        if(likename!=null&&!likename.equals("")){
            qw.like("complaints_name",likename);
        }
        IPage<HyComplaints> iPage = hyComplaintsMapper.selectPage(page,qw);
        return iPage;
    }

    @Override
    public List<StateMonth> selectByMonth() {
        return hyComplaintsMapper.selectByMonth();
    }

    @Override
    public List<StateMonth> selectByMonth2() {
        return hyComplaintsMapper.selectByMonth2();
    }

}
